package com.dq.domain.sys.user;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.user.user.base.SysUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @author liuhui
 * @date 2019/11/23 0023 15:15:48
 */
@Data
@Entity
@ApiModel("用户喜好中间表")
public class UserHobby extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("用户")
    @ManyToOne
    protected SysUser sysUser;

    @ApiModelProperty("喜好")
    @ManyToOne
    protected Hobby hobby;

    @Data
    @ApiModel(value = "用户喜好视图")
    public static class Vo implements VO {
        protected Long id;
        protected String name;
    }
    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo=new Vo();
        vo.id = this.getId();
        vo.name = fmt(this.getHobby().getName());
        return vo;
    }
}
